<include file="header" />
<body>
<div class="wraper margin-none">
    <div class="top">
        <a href="javascript:history.go(-1);" class="iconfont icon-zuo pull-left"></a>
        <span class="pull-left">历史记录</span>
        <a href="{BEESCRM::U('base/ips/index',array('ips_id'=>$ips_id))}" class="iconfont icon-shouye pull-right text-right"></a>
    </div>
    <div class="tab-box clearfix">
	    <a href="{BEESCRM::U('base/ips/chargeLog',array('ips_id'=>$ips_id))}" class="tab-list">充值记录</a>
	    <a href="{BEESCRM::U('base/ips/eleInfo',array('ips_id'=>$ips_id))}" class="tab-list visited">用电记录</a>
    </div>
    <!--有记录-->
    <empty name="data" >
        <!--无记录-->
        <div class="none-list"><img src="/assets/base/cleaning/images/none-list.png"/></div>
        <else />
        <volist name="data" id="vo">
            <div class="lists">
                <p class="text-gray">{BEESCRM:$vo.last_time|date="Y-m-d H:i:s",###}</p>
                <p class="text-12">当日用电量（度）<span class="pull-right">{BEESCRM::number_format(($vo[first_ele] - $vo[last_ele]),2)}</span></p>
            </div>
        </volist>
        <div class="datalist">

        </div>

        <div class="loadmore">加载中</div>
    </empty>
    <input type="hidden" id="pagecount" value="{BEESCRM:$pageCount}">
</div>
<include file="commonJS" />
<script>
    $(function(){
        var page = 1;
        var pageCount = $("#pagecount").val();
        $(window).scroll(function() {
            //当内容滚动到底部时加载新的内容
            if ($(window).scrollTop() + $(window).height() + 20 > $(document).height()) {
                //当前要加载的页码

                page++;
                if(page <= pageCount){
                    LoadPage(page);
                }

            }
        });

        function LoadPage(page){
            var ips_id = "{BEESCRM:$ips_id}";
            $.ajax({
                'url': "/base/ips/eleInfoAjax",
                'data': {p:page,ips_id:ips_id},
                'dataType':'json',
                'type': 'GET',
                'async': false,
                success: function(data){
                    if(data.status == 'S'){
                        var info = data.result;
                        $(info).each(function(idx) {
                            var val = info[idx];
                            var energy = val['last_ele'] - val['first_ele'];
                            $('.datalist').append('<div class="lists"><p class="text-gray">'+val['last_time']+'</p><p class="text-12">当日用电量（度）<span class="pull-right">'+energy.toFixed(2)+'</span></p> </div>');
                        });
                    }
                }
            });
        }
    });

</script>
</body>
</html>